home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-22 | 3.6 KB | 128 lines | [TEXT/GEOL] |
- Item 8546692 21-Dec-89 13:55
-
- From: V0230 Trace, Laurence Kirsh,VAR
-
- To: D5369 Mgmt Sys Des, Chuck McMath,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: re- Associating Two Files
-
- Chuck,
-
- I had a vaguely similar situation in TRS. There, the application held a STR
- resource which was the complete pathname of the folder which held all the data
- files. (This was safe since it was on a server and a network administrator kept
- the name from changing). The application automatically used that path to open
- all document files.
-
- What I did was convert the pathname into a working directory number
- (gDataWDNum), and passed that to gApplication.OpenOld:
-
- {====================================================}
- . . .
- {fill in the record used to open the file}
- With FileData Do Begin
- vRefNum := gDataWDNum;
- fType := kDocFileType;
- VersNum := 0; {obsolete}
- fName := SelectedInfo.FileName
- End;
-
- CatchFailures (fi, HandleOpenFailure);
-
- {open the file as an old file}
- gApplication.OpenOld (cOpen, FileData);
-
- Success (fi);
- {====================================================}
-
- The code used to initialize that global is given below. The PBOpenWD call is
- what you want, I think. Once I change the volume in here, it stays changed, but
- I don't think that is necessary for this to work.
-
- {====================================================}
- {$S AInit}
- Procedure InitFileUnit;
- {initialize gDataWDNum}
-
- Var
- MyWDPB: WDPBRec; {to find our vol ref number}
- LocalName: Str255; {space for PB calls}
-
- PathName: Str255;
- TempPath: StringHandle;{used to fetch search path resource string}
-
- Begin
- If Not gConfiguration.HasHFS
- Then gDataWDNum := 0{not sure this will work, really we shouldn't run in
- this case}
-
- Else Begin
- {--- get search path}
- TempPath := GetString (kSearchPathID);
- If TempPath = Nil
- Then PathName := ''
- Else PathName := TempPath^^;
- ReleaseResource (Handle(TempPath));
- {$IFC qDebug}
- Writeln ('Search Path = "',PathName,'"');
- {$ENDC}
-
-
- {--- use search path to set default volume and directory}
- With MyWDPB Do Begin
- ioCompletion := Nil;
- ioNamePtr := @PathName;
- ioVRefNum := -32768; {means "unknown" see end of TN77}
- ioWDDirID := 0
- End;
-
- If PBHSetVol (@MyWDPB, False) <> noErr Then Begin
- ParamText (PathName, '', '', '');
- StdAlert (kSetVolAlertID)
- {If the SetVol fails then the rest of this code should
- execute on the current directory (where the application is)}
- End;
-
-
- {--- now get the default VRefNum and DirID}
- With MyWDPB Do Begin
- ioCompletion := Nil;
- ioNamePtr := @LocalName
- End;
-
- FailOSErr (PBHGetVol (@myWDPB, False));
-
-
- {--- make a WD from the default VRefNum and DirID}
- With MyWDPB Do Begin
- ioCompletion := Nil;
- ioNamePtr := Nil;
- ioVRefNum := ioWDVRefNum; {from GetVol call}
- ioWDProcID := LongInt('ERIK'); {see TN 77}
- { ioWDDirID already set}{from GetVol call}
- End;
-
- FailOSErr (PBOpenWD (@MyWDPB, False));
-
-
- {--- finally, what we want: a working directory for the search path}
- gDataWDNum := MyWDPB.ioVRefNum;
-
- {$IFC qDebug}
- ;Writeln ('gDataWDNum = ',gDataWDNum:0);
- {$ENDC}
- End
-
- End; {InitFileUnit}
- {=======================================================}
-
- I think what you need to do is use your saved file info to create the working
- directory number, and then use that to open the files.
-
- --John MacVeigh
-
- P.S. Merry Christmas from what's left of Trace... err make that IRC-Arlington!
-
-